<?php


require_once '/data/wwwroot/package/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
ini_set('memory_limit', '2048M');



$message = $argv[1] ?? '';
$severity = $argv[2] ?? 'anonymous.info';
if (!strlen($message)) exit('no message');

try {
    \tools\TTime::timeRecordBegin();
    foreach (range(1, 5000) as $i) {

        $messageI = $message . "[$i]";

//        \core\CRabbitMQSimple::getInstance()->connect()->setPublisherConfirms()->send($messageI);
        \core\CRabbitMQSimple::getInstance()->connect()->send($messageI);

        echo " [x] Sent '$messageI'", PHP_EOL;
    }

    echo \tools\TTime::timeRecordPoint(), PHP_EOL;
//    \core\CRabbitMQFanout::getInstance()->connect()->send($message, $severity);
//    \core\CRabbitMQTopic::getInstance()->connect()->send($message, $severity);

} catch (Exception $e) {
    //PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false'
    echo " [x] Sent error : ", $e->getMessage(), PHP_EOL;
}


